package JdbcTemplate.operation.query;

import JdbcTemplate.config.Config;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.jdbc.core.JdbcOperations;

public class Query {

    public static void main(String[] args) {

        //查询语句
        String query="SELECT * FROM spitter WHERE id_identity=?;";

        ApplicationContext configApplicationContext=new AnnotationConfigApplicationContext(Config.class);

        JdbcOperations jdbcOperations= (JdbcOperations) configApplicationContext.getBean("jdbcOperations");

            /*
            可以在此处通过匿名内部类/Lambda表达式获取结果集
            query:sql语句
            PersonMapper():RowMapper实现类
            objects:sql查询语句的参数值
             */
            //不使用预处理语句去掉该参数即可
        jdbcOperations.queryForObject(query,new PersonMapper(),10);


    }
}
